package com.neborosoft.lib.threading;

import android.os.Handler;

/**
 * Created with IntelliJ IDEA.
 * User: CM
 * Date: 06.01.13
 * Time: 23:55
 * To change this template use File | Settings | File Templates.
 */
public final class OnUiThreadExecutor {
    private static Handler handler = new Handler();
    private static Thread thread = Thread.currentThread();

    public static void run(Runnable runnable) {
        if(thread == Thread.currentThread()){
            runnable.run();
        }
        else {
            handler.post(runnable);
        }
    }
}
